package com.briup.srms.sms.web.controller;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.briup.srms.sms.bean.ClazzLog;
import com.briup.srms.sms.service.IClazzLogService;
import com.jacky.base.utils.Message;
import com.jacky.base.utils.MessageUtil;
import com.jacky.base.utils.PageVM;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @program: 杰普基础管理系统
 * @description: 班级日志管理的控制器类
 * @author: charles
 * @create: 2021-3-9 15:09
 **/
@Api(description="班级日志相关接口")
@Validated
@RestController
@RequestMapping("/clazzLog")
public class ClazzLogController {
	@Autowired
	private IClazzLogService clazzLogService;

	@ApiOperation(value = "查询班级日志")
    @GetMapping("findClazzLog")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "logDate", value = "日志时间", paramType = "query"),
		@ApiImplicitParam(name = "clazzId", value = "班级编号", paramType = "query")
	})
    public Message findClazzLog(String logDate,Long clazzId){
        System.out.println("【clazz.findClazzLog】");
		ClazzLog clazz = clazzLogService.findClazzLog(logDate, clazzId);
        return MessageUtil.success(clazz);
    }

	@ApiOperation(value = "分页查询班级日志")
    @GetMapping("pageQuery")
	@ApiImplicitParams({
		@ApiImplicitParam(name = "page", value = "当前页", required = true, paramType = "query"),
		@ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, paramType = "query"),
		@ApiImplicitParam(name = "logDate", value = "日志时间", paramType = "query"),
		@ApiImplicitParam(name = "clazzId", value = "班级编号", paramType = "query")
	})
    public Message pageQuery(@NotNull Integer page,@NotNull Integer pageSize,String logDate,Long clazzId){
        System.out.println("【clazz.pageQuery】");
		PageVM<ClazzLog> list = clazzLogService.pageQuery(page, pageSize, logDate, clazzId);
        return MessageUtil.success(list);
    }

	@ApiOperation(value = "保存或更新")
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(ClazzLog clazzLog){
        System.out.println("【clazz.saveOrUpdate】");
		clazzLogService.saveOrUpdate(clazzLog);
        return MessageUtil.success("操作成功");
    }

	@ApiOperation(value = "根据ID删除")
    @GetMapping("deleteById")
    public Message deleteById(@NotNull long id){
        System.out.println("【clazz.deleteById】");
		clazzLogService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

}
